<style>
    fieldset{
        width: 200px
    }
</style>

<form id="formSerie">
<table width="100%" border="0">
  <tr>
    <td width="10%">S&eacute;rie:</td>
    <td width="11%">Ano:</td>
    <td width="15%">Turno:</td>
    <td width="14%">Turma:</td>
    <td width="14%">N&uacute;mero:</td>
    <td width="9%">Desconto:</td>
  </tr>
  <tr>
    <td>
      <select name="serie" id="serie">
          <?php $this->load->view('serie/cbo_serie'); ?>
      </select>        </td>
    <td>
        <select name="anoSerie" id="anoSerie" readonly>
            <option value="">Selecione</option>
        </select>
    </td>    
    <td>
        <select name="turnoSerie" id="turnoSerie" readonly>
            <option value="">Selecione</option>
        </select>
      
    <td>
        <select name="turmaSerie" id="turmaSerie" readonly>
            <option value="">Selecione</option>
        </select>
    </td>
    <td><input type="text" size="5" maxlength="4" name="numeroSerie" id="numeroSerie" /></td>
    <td><input type="text" size="5" maxlength="2" name="descontoSerie" id="descontoSerie" /></td>
  </tr>
</table>
<br />
<table width="100%" border="0">
  <tr>
    <td width="18%" rowspan="2">
      <fieldset>
      <legend>Transporte Escolar P&uacute;blico</legend>
      <br />
          <input type="radio" value="1" id="transpEscolar" name="transpEscolar" />
        Sim &nbsp;
          <input type="radio"  value="0" id="transpEscolar" name="transpEscolar" />
        N&atilde;o
      <br /><br />
      </fieldset>    </td>
    <td width="14%">&nbsp;</td>
    <td width="17%" colspan="2" rowspan="5">
        <fieldset >
      <legend>Condi&ccedil;&atilde;o do aluno</legend>
      <br />
          <input type="radio" value="1" id="condicaoAluno" name="condicaoAluno"/>
        Promovido <br /><br />
          <input type="radio" value="0" id="condicaoAluno" name="condicaoAluno" />
        Repetente <br /><br />
          <input type="radio" value="0" id="condicaoAluno" name="condicaoAluno" />
        Fequentou a EJA ano anterior <br /><br />
          <input type="radio"  value="0" id="condicaoAluno" name="condicaoAluno" />
        N&atilde;o fequentou escola ano anterior <br /><br />
       
      <br />
      </fieldset>    </td>
    <td width="17%">&nbsp;</td>
    <td width="17%" rowspan="3">
    
    <fieldset>
      <legend>Idiomas</legend>
      <br />
          <input type="radio" value="0" id="idioma" name="idioma"/>
        N&atilde;o<br /><br />
          <input type="radio"  value="1" id="idioma" name="idioma" />
        Ingl&ecirc;s
      <br />
      <br />
          <input type="radio"  value="2" id="idioma" name="idioma" />
            Espanhol
          <br /><br />
      </fieldset>    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td rowspan="2">
    <fieldset>
      <legend>Classe Comum</legend>
      <br />
          <input type="radio" value="1" id="classeComum" name="classeComum" />
        Sim &nbsp;
          <input type="radio"  value="0" id="classeComum"  name="classeComum" />
        N&atilde;o
      <br /><br />
      </fieldset>    </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td rowspan="2">
    <fieldset>
      <legend>Ped. Especializado</legend>
      <br />
          <input type="radio" value="1" id="pedEspecializado" name="pedEspecializado"/>
        Sim &nbsp;
          <input type="radio"  value="0" id="pedEspecializado" name="pedEspecializado" />
        N&atilde;o
      <br /><br />
      </fieldset>	</td>
    <td>&nbsp;</td>
    <td colspan="2" rowspan="2">
    <fieldset>
      <legend>Programa Bolsa Fam&iacute;lia</legend>
      <br />
          <input type="radio" value="1" id="bolsaFamilia" name="bolsaFamilia"/>
        Sim &nbsp;
          <input type="radio"  value="0" id="bolsaFamilia" name="bolsaFamilia" />
        N&atilde;o
      <br /><br />
      </fieldset>    </td>
    <td>&nbsp;</td>
    <td rowspan="2">
    <fieldset>
      <legend>Outros</legend>
      <br />
          <input type="checkbox" value="1" id="pas" name="pas"/>
        PAS &nbsp;&nbsp;
          <input type="checkbox"  value="0" id="convenio" name="convenio" />
        Conv&ecirc;nio
      <br /><br />
      </fieldset>
    </td>
  </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
    <tr>
        <td colspan="6" >
            <div align="center">
                <input type="hidden" id="alunoId" value="<?= $alunoId ?>" />
                <input type="button" value="Gravar dados acad&ecirc;micos" id="btnDadosAcademicos" />
            </div>
        </td>

  </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
</form>

<script>
    $(document).ready(function(){
       
        $('#serie').change(function(){
            
            var serieCod = jQuery('select[id="serie"]').val();
            
            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=loadAno',
                cache: false,
                data: {serieCod:serieCod},
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                    
                   $('#anoSerie').attr('readonly',false);
                   $('#anoSerie').html(data);
                   
                }
            });

        });
        
        $('#anoSerie').change(function(){
            
            var serieCod = jQuery('select[id="serie"]').val();
            var anoLetivo= jQuery('select[id="anoSerie"]').val();
            
            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=loadTurno',
                cache: false,
                data: {
                    serieCod:serieCod,
                    anoLetivo:anoLetivo
                },
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                   
                   $('#turnoSerie').attr('readonly',false);
                   $('#turnoSerie').html(data);
                   
                }
            });

        });
        
        $('#turnoSerie').change(function(){
            
            var serieCod = jQuery('select[id="serie"]').val();
            var anoLetivo= jQuery('select[id="anoSerie"]').val();
            var turnoCod= jQuery('select[id="turnoSerie"]').val();
            
            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=loadTurma',
                cache: false,
                data: {
                    serieCod:serieCod,
                    anoLetivo:anoLetivo,
                    turnoCod:turnoCod
                },
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                   
                   $('#turmaSerie').attr('readonly',false);
                   $('#turmaSerie').html(data);
                   
                }
            });

        });
        
        $('#btnDadosAcademicos').click(function(){
            
            var serieCod    = jQuery('select[id="serie"]').val();
            var anoLetivo   = jQuery('select[id="anoSerie"]').val();
            var turnoCod    = jQuery('select[id="turnoSerie"]').val();
            var turmaCod    = jQuery('select[id="turmaSerie"]').val(); 
            var alunoId     = jQuery('input[id="alunoId"]').val();
            
            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=gravarDadosAcademicos',
                cache: false,
                data: {
                    serieCod:serieCod,
                    anoLetivo:anoLetivo,
                    turnoCod:turnoCod,
                    turmaCod:turmaCod,
                    alunoId:alunoId
                },
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                  
                   if(data == true){
                       
                       alert('Dados inseridos com sucesso!');
                       
                   } else if(data == 888){
                       
                       alert('Acesso negado!');
                       
                   } else
                       alert('Ocorreu um erro ao inserir os dados. Por favor tente novamente.');
                   
                }
            });

        });
        
    });
</script>